package com.s59.controller;

import com.s59.entity.User;
import com.s59.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping
    public List<User> getall(){
        return userService.getall();
    }
    @GetMapping("/{id}")
    public User get(@PathVariable Long id){
        return userService.get(id);
    }
    @PostMapping
    public Long add(@RequestBody User department){
        return userService.add(department);
    }
    @DeleteMapping("/{id}")
    public int del(@PathVariable Long id){
        return userService.del(id);
    }
    @PutMapping
    public Long update(@RequestBody User department){
        return userService.update(department);

    }
}
